package cn.kxx.controller;

import cn.kxx.constant.MessageConstant;
import cn.kxx.entity.Result;
import cn.kxx.pojo.Order;
import cn.kxx.service.OrderService;
import cn.kxx.vo.OrderInfoVo;
import cn.kxx.vo.OrderInfoVo2;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

@Api(tags = "预约服务")
@RestController
@RequestMapping("/order")
public class OrderController {
    @Reference
    private OrderService orderService;

    @ApiOperation("微信预约")
    @PostMapping("/submit")
    public Result submitWechat(@RequestBody OrderInfoVo orderInfoVo){
        orderInfoVo.setOrderType(Order.ORDERTYPE_WEIXIN);
        int orderId = orderService.submit(orderInfoVo);
        return new Result(true, MessageConstant.ORDER_SUCCESS,orderId);

    }

    /**
     * 根据id查询预约信息，包括套餐信息和会员信息
     * @param id
     */
    @ApiOperation("预约信息展示,包括套餐信息和会员信息")
    @GetMapping("/findById/{id}")
    public Result findById(@PathVariable("id") Integer id){
        OrderInfoVo2 orderInfoVo2 = orderService.findById(id);
        return new Result(true,MessageConstant.QUERY_ORDER_SUCCESS,orderInfoVo2);
    }
}
